package com.example.gridview;

import java.util.List;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ListView;

import com.example.gridview.adapters.StaggeredAdapter;
import com.origamilabs.library.views.StaggeredGridView;

public class GridActivity extends Activity
{
	
	
	CommentsManager mgrComment;
	Button btnAdd, btnDelete;
	ListView list1, list2;
	private String[] list1Text = {
            "Hello hello hello Hello Hello hello hello HelloHello hello hello Hellothis is a test", "Hello this is a test. and here is some more text", "Hello hello hello HelloHello hello hello Hello Hello this is a test", "Hello this is a test. and here is some more text", "Hello this is a test","Hello this is a test", "Hello this is a test. and here is some more text", "Hello this is a test",
            "Hello hello hello Hello Hello hello hello HelloHello hello hello Hellothis is a test Hello hello hello Hello Hello hello hello HelloHello hello hello Hellothis is a test Hello hello hello Hello Hello hello hello HelloHello hello hello Hellothis is a test Hello hello hello Hello Hello hello hello HelloHello hello hello Hellothis is a test Hello hello hello Hello Hello hello hello HelloHello hello hello Hellothis is a test"
    };
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	    setContentView(R.layout.main);
	    
	    
	    mgrComment = new CommentsManager(this);
	    mgrComment.open();
	    
StaggeredGridView gridView = (StaggeredGridView) this.findViewById(R.id.staggeredGridView1);
		
		int margin = getResources().getDimensionPixelSize(R.dimen.margin);
		
		gridView.setItemMargin(margin); // set the GridView margin
		
		gridView.setPadding(margin, 0, margin, 0); // have the margin on the sides as well 
		
		StaggeredAdapter adapter = new StaggeredAdapter(this, R.id.txtNote, list1Text);
		
		gridView.setAdapter(adapter);
		adapter.notifyDataSetChanged();	    
	   
	    
	   
	    List<Comment> values = mgrComment.getAllComments();

	    	}
	
	protected void onResume(){
		super.onResume();
		mgrComment.open();
	}

	protected void onPause(){
		super.onPause();
		mgrComment.close();
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.grid, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	/**
	 * A placeholder fragment containing a simple view.
	 */
	public static class PlaceholderFragment extends Fragment {

		public PlaceholderFragment() {
			
		}

		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {
			View rootView = inflater.inflate(R.layout.fragment_grid, container,
					false);
			return rootView;
		}
	}
	
}
